var express = require('express');
var router = express.Router();
const NoteService = require('../services/NoteService');
const TodoService = require('../services/TodoService');
router.get('/', async function (req, res, next) {
    let ntDatas = await NoteService.getAllNotes(req.session.uid)
    let doneDatas = await TodoService.getDones(req.session.uid)
    let updoneDatas = await TodoService.getUpDones(req.session.uid)
    if (req.session.uid) {
        console.log(doneDatas);
        res.render('home', {
            uname: req.session.user,
            uid: req.session.uid,
            ntDatas,
            doneDatas,
            updoneDatas,
            notenum: ntDatas.length,
            todonum: doneDatas.length + updoneDatas.length
        });
    } else {
        res.render('index', { title: '未登录' });
    }
});
module.exports = router;